<template>
  <a-space align="center" style="margin-bottom: 16px">
    CheckStrictly:
    <a-switch v-model:checked="rowSelection.checkStrictly"></a-switch>
  </a-space>
  <a-table rowKey="taskId" :columns="columns" :data-source="data" :row-selection="rowSelection" />
</template>
<script lang="ts" setup>
import { ref } from 'vue';
const columns = [
  {
    title: '项目阶段',
    dataIndex: 'milepostName',
    resizable: true,
    ellipsis: true,
    width: '250px',
    fixed: 'left',
    align: 'left',
    customCell: ({ rowSpan }) => {
      return {
        rowSpan: rowSpan
      }
    }
  },
  {
    title: '序号',
    dataIndex: 'taskIndex',
    resizable: true,
    ellipsis: true,
    width: '70px',
    fixed: 'left',
    align: 'left',
    customCell: ({ level, nodeType }) => {
      return {
        style: {
          paddingLeft: `${(level + 1) * 15}px`,
          color: `${nodeType === 'MENU' ? '#1890ff' : ''}`
        }
      }
    }
  },
  {
    title: '任务名称',
    dataIndex: 'taskName',
    ellipsis: true,
    resizable: true,
    width: '250px',
    fixed: 'left',
    align: 'left',
    customCell: ({ level, nodeType }) => {
      return {
        style: {
          paddingLeft: `${(level + 1) * 20}px`,
          color: `${nodeType === 'MENU' ? '#1890ff' : ''}`
        }
      }
    }
  },
  {
    title: '任务状态',
    dataIndex: 'taskStatus',
    resizable: true,
    ellipsis: false,
    width: '140px',
    align: 'center'
  },
  {
    title: '计划开始',
    dataIndex: 'startTime',
    resizable: true,
    ellipsis: true,
    width: '140px',
    align: 'center'
  },
  {
    title: '实际开始',
    dataIndex: 'actualStarTime',
    resizable: true,
    ellipsis: true,
    width: '140px',
    align: 'center'
  },
  {
    title: '计划完成',
    dataIndex: 'endTime',
    ellipsis: true,
    width: '120px',
    resizable: true,
    align: 'center'
  },
  {
    title: '	实际完成',
    dataIndex: 'taskFinishTime',
    ellipsis: true,
    resizable: true,
    width: '120px',
    align: 'center'
  },
  {
    title: '任务负责人',
    dataIndex: 'taskOwner',
    resizable: true,
    ellipsis: true,
    width: '140px',
    align: 'center'
  },
  {
    title: '审批状态',
    dataIndex: 'approvalStatus',
    resizable: true,
    ellipsis: true,
    width: '200px',
    align: 'center'
  },
  {
    title: '优先级',
    dataIndex: 'priorityStr',
    resizable: true,
    ellipsis: true,
    width: '150px',
    align: 'center'
  },
  {
    title: '未关闭风险数量',
    dataIndex: 'unclosedRiskNumber',
    resizable: true,
    ellipsis: true,
    width: '160px',
    align: 'center'
  },
  {
    title: '风险数量',
    dataIndex: 'riskNumber',
    resizable: true,
    ellipsis: true,
    width: '160px',
    align: 'center'
  },
  {
    title: '任务编码',
    dataIndex: '',
    ellipsis: true,
    resizable: true,
    width: '160px',
    align: 'center'
  },

  {
    title: '计划工时',
    dataIndex: 'workingHours',
    resizable: true,
    ellipsis: true,
    width: '100px',
    align: 'center'
  },
  {
    title: '实际工时',
    dataIndex: 'actualWorkHours',
    resizable: true,
    ellipsis: true,
    width: '100px',
    align: 'center'
  },
  {
    title: '工时投入状态',
    dataIndex: 'stateInput',
    resizable: true,
    ellipsis: true,
    width: '200px',
    align: 'center'
  },
  {
    title: '审核员',
    dataIndex: 'assessorName',
    resizable: true,
    ellipsis: true,
    width: '140px',
    align: 'center'
  },

  {
    title: '任务参与人',
    resizable: true,
    dataIndex: 'taskParticipantStr',
    ellipsis: true,
    width: '140px',
    align: 'center'
  },
  {
    title: '任务类型',
    dataIndex: 'taskType',
    resizable: true,
    ellipsis: true,
    width: '200px',
    align: 'center'
  },

  {
    title: '备注',
    dataIndex: 'description',
    resizable: true,
    ellipsis: true,
    width: '100px',
    align: 'center'
  },
  {
    title: '附件',
    dataIndex: 'attachment',
    resizable: true,
    ellipsis: true,
    width: '200px',
    align: 'center'
  },
  {
    title: '任务上下线',
    dataIndex: 'taskStatusOnOrOff',
    resizable: true,
    ellipsis: true,
    width: '120px',
    align: 'center'
  },
  {
    title: '依赖任务',
    dataIndex: 'taskDependency',
    resizable: true,
    ellipsis: true,
    width: '100px',
    align: 'center'
  },
  {
    title: '操作',
    dataIndex: 'operation',
    width: '430px',
    align: 'center'
  }
]

interface DataItem {
  key: number;
  name: string;
  age: number;
  address: string;
  children?: DataItem[];
}

const data: DataItem[] = [
  {
    "key": 1,
    "taskId": 4,
    "parentId": 0,
    "dailyItemId": null,
    "milepostId": 2498,
    "milepostName": null,
    "serialNumber": null,
    "projectId": 724,
    "projectName": null,
    "description": null,
    "delFlag": 0,
    "taskName": "测试任务1",
    "taskDependency": null,
    "taskDependencyArray": null,
    "taskOwner": "胡耕永",
    "taskParticipantList": [
      "胡耕永",
      "张尧尧"
    ],
    "taskParticipantOthersList": null,
    "taskParticipantStr": "胡耕永,张尧尧",
    "taskParticipantOthersStr": null,
    "startTime": "2023-07-10",
    "endTime": "2023-07-11",
    "daysOfDelay": "22",
    "workingHours": 20,
    "taskType": "主任务",
    "assessor": 100414,
    "assessorName": "胡耕永",
    "priority": "HIGHEST",
    "priorityStr": "最高",
    "actualStarTime": null,
    "taskFinishTime": null,
    "actualWorkHours": 0,
    "stateInput": "正常",
    "taskStatus": "延期",
    "instanceId": "bd7689b5-269c-11ee-9ad3-1270dc64e01b",
    "ppmEnclosureInfoList": [],
    "attachment": null,
    "riskNumber": 0,
    "unclosedRiskNumber": 0,
    "managerList": null,
    "carbonCopyNameList": null,
    "operationFlag": 0,
    "pmName": "胡耕永",
    "plName": null,
    "taskStatusOnOrOff": true,
    "projectSwitch": "true",
    "taskAssignerName": null,
    "output": "是",
    "attachmentStatus": "true",
    "taskIndex": 1,
    "approvalStatus": "胡耕永-修改任务-审批中",
    "children": null,
    "rejectTheTask": null,
    "nodeType": "TASK",
    "virtualRealStatus": "VIRTUAL",
    "realTaskId": null,
    "operationType": "UPDATE",
    "uploadPermission": true,
    "previewPermission": true,
    "finishPermission": true,
    "projectManager": true,
    "isRiskOrNo": false
  },
  {
    "key": 2,
    "taskId": 2,
    "parentId": 0,
    "dailyItemId": null,
    "milepostId": 2498,
    "milepostName": null,
    "serialNumber": null,
    "projectId": 724,
    "projectName": null,
    "description": null,
    "delFlag": 0,
    "taskName": "测试任务父级任务",
    "taskDependency": null,
    "taskDependencyArray": null,
    "taskOwner": null,
    "taskParticipantList": null,
    "taskParticipantOthersList": null,
    "taskParticipantStr": null,
    "taskParticipantOthersStr": null,
    "startTime": null,
    "endTime": null,
    "daysOfDelay": null,
    "workingHours": null,
    "taskType": null,
    "assessor": null,
    "assessorName": null,
    "priority": null,
    "priorityStr": null,
    "actualStarTime": null,
    "taskFinishTime": "2023-07-11",
    "actualWorkHours": 0,
    "stateInput": null,
    "taskStatus": null,
    "instanceId": "bd7689b5-269c-11ee-9ad3-1270dc64e01b",
    "ppmEnclosureInfoList": [],
    "attachment": null,
    "riskNumber": null,
    "unclosedRiskNumber": null,
    "managerList": null,
    "carbonCopyNameList": null,
    "operationFlag": 1,
    "pmName": "胡耕永",
    "plName": null,
    "taskStatusOnOrOff": true,
    "projectSwitch": null,
    "taskAssignerName": null,
    "output": null,
    "attachmentStatus": "true",
    "taskIndex": 2,
    "approvalStatus": "胡耕永-完成任务-已通过",
    "children": [
      {
        "key": 21,
        "taskId": 3,
        "parentId": 2,
        "dailyItemId": null,
        "milepostId": 2498,
        "milepostName": null,
        "serialNumber": null,
        "projectId": 724,
        "projectName": null,
        "description": null,
        "delFlag": 0,
        "taskName": "111",
        "taskDependency": null,
        "taskDependencyArray": null,
        "taskOwner": "胡耕永",
        "taskParticipantList": [
          "胡耕永",
          "张尧尧"
        ],
        "taskParticipantOthersList": null,
        "taskParticipantStr": "胡耕永,张尧尧",
        "taskParticipantOthersStr": null,
        "startTime": "2023-07-10",
        "endTime": "2023-07-12",
        "daysOfDelay": "21",
        "workingHours": 44,
        "taskType": "主任务",
        "assessor": 100414,
        "assessorName": "胡耕永",
        "priority": "HIGHEST",
        "priorityStr": "最高",
        "actualStarTime": "2023-07-11",
        "taskFinishTime": "2023-07-11",
        "actualWorkHours": 19,
        "stateInput": "正常",
        "taskStatus": "完成",
        "instanceId": "bd7689b5-269c-11ee-9ad3-1270dc64e01b",
        "ppmEnclosureInfoList": [
          {
            "enclosureId": null,
            "uid": "vc-upload-1688972275349-5",
            "name": "17178c2ebdf04d565b09100a5c0e7412_1051x753.webp.jpg",
            "imgUrl": null,
            "size": 168651,
            "status": "done",
            "type": "image/jpeg",
            "url": "https://fastdfs-stage.allintechinc.com:8888/group1/M00/02/7B/rBUAHWSrrWWAZHjEAAKSy0yNAts049.jpg",
            "delFlag": null,
            "projectId": null
          }
        ],
        "attachment": "17178c2ebdf04d565b09100a5c0e7412_1051x753.webp.jpg",
        "riskNumber": 3,
        "unclosedRiskNumber": 1,
        "managerList": null,
        "carbonCopyNameList": null,
        "operationFlag": 0,
        "pmName": "胡耕永",
        "plName": null,
        "taskStatusOnOrOff": true,
        "projectSwitch": "true",
        "taskAssignerName": null,
        "output": "是",
        "attachmentStatus": "true",
        "taskIndex": 3,
        "approvalStatus": "胡耕永-完成任务-已通过",
        "children": null,
        "rejectTheTask": null,
        "nodeType": "TASK",
        "virtualRealStatus": "REAL",
        "realTaskId": null,
        "operationType": "CREAT",
        "uploadPermission": true,
        "previewPermission": true,
        "finishPermission": true,
        "projectManager": true,
        "isRiskOrNo": true
      },
      {
        "key": 22,
        "taskId": 5,
        "parentId": 2,
        "dailyItemId": null,
        "milepostId": 2498,
        "milepostName": null,
        "serialNumber": null,
        "projectId": 724,
        "projectName": null,
        "description": null,
        "delFlag": 0,
        "taskName": "111",
        "taskDependency": null,
        "taskDependencyArray": null,
        "taskOwner": "胡耕永",
        "taskParticipantList": [
          "胡耕永",
          "张尧尧"
        ],
        "taskParticipantOthersList": null,
        "taskParticipantStr": "胡耕永,张尧尧",
        "taskParticipantOthersStr": null,
        "startTime": "2023-07-10",
        "endTime": "2023-07-12",
        "daysOfDelay": "21",
        "workingHours": 44,
        "taskType": "主任务",
        "assessor": 100414,
        "assessorName": "胡耕永",
        "priority": "HIGHEST",
        "priorityStr": "最高",
        "actualStarTime": null,
        "taskFinishTime": null,
        "actualWorkHours": 0,
        "stateInput": "正常",
        "taskStatus": "延期",
        "instanceId": "bd7689b5-269c-11ee-9ad3-1270dc64e01b",
        "ppmEnclosureInfoList": [],
        "attachment": null,
        "riskNumber": 0,
        "unclosedRiskNumber": 0,
        "managerList": null,
        "carbonCopyNameList": null,
        "operationFlag": 0,
        "pmName": "胡耕永",
        "plName": null,
        "taskStatusOnOrOff": true,
        "projectSwitch": "true",
        "taskAssignerName": null,
        "output": "是",
        "attachmentStatus": "true",
        "taskIndex": 3,
        "approvalStatus": "胡耕永-修改任务-审批中",
        "children": null,
        "rejectTheTask": null,
        "nodeType": "TASK",
        "virtualRealStatus": "VIRTUAL",
        "realTaskId": null,
        "operationType": "UPDATE",
        "uploadPermission": true,
        "previewPermission": true,
        "finishPermission": true,
        "projectManager": true,
        "isRiskOrNo": false
      }
    ],
    "rejectTheTask": null,
    "nodeType": "MENU",
    "virtualRealStatus": "REAL",
    "realTaskId": null,
    "operationType": null,
    "uploadPermission": false,
    "previewPermission": false,
    "finishPermission": false,
    "projectManager": false,
    "isRiskOrNo": null
  }

]
const rowSelection = ref({
  checkStrictly: false,
  onChange: (selectedRowKeys: (string | number)[], selectedRows: DataItem[]) => {
    console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
  }
});
</script>

